﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;

namespace Notepad_Clone
{
    partial class NotepadClone
    {
        MenuItem itemStatus;

       void AddViewMenu(Menu menu)
        {
            MenuItem itemView = new MenuItem();
            itemView.Header = "_View";
            itemView.SubmenuOpened += this.ViewOnOpen;
            menu.Items.Add(itemView);

            this.itemStatus = new MenuItem();
            this.itemStatus.Header = "_Status Bar";
            this.itemStatus.IsCheckable = true;
            this.itemStatus.Checked += this.StatusOnCheck;
            this.itemStatus.Unchecked += this.StatusOnCheck;
            itemView.Items.Add(this.itemStatus);
        }

        private void StatusOnCheck(object sender, RoutedEventArgs e)
        {
            MenuItem item = sender as MenuItem;
            this.status.Visibility = item.IsChecked ? Visibility.Visible : Visibility.Collapsed;
        }

        private void ViewOnOpen(object sender, RoutedEventArgs e)
        {
            this.itemStatus.IsChecked = (this.status.Visibility == Visibility.Visible);
        }
    }
}
